app.controller("reviseclassController",function($scope, $http,$routeParams){
    $scope.pact_id=$routeParams.id;
    console.log($scope.pact_id)
    $scope.class_name=$routeParams.class_name;
    // 报课单列表
    $http({
        method: 'POST',
        url: '/OA/enrolclazz/list ',
        data:$.param({pact_id:$scope.pact_id}),
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    }).success(function (response) {
        console.log(response)
        $scope.total = response.total;
        //反转函数转化abcd转dcba
        $scope.data = response.data;
        $scope.enrol_datas = response.data;
        $scope.arrs=$scope.enrol_datas;
        console.log($scope.arrs)
        // 定义一个单击删除按钮时触发的事件，用于删除选中行
        $scope.delete = function($index){
            if ($index>=0) {
                if(confirm("是否删除"+$scope.arrs[$index].sn+"的排课么") ){
                    $http({
                        method:"POST",
                        url:'/OA/enrolclazz/delete ',
                        data:$.param({id:$scope.arrs[$index].id}),
                        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
                    }).success(function (result) {
                        $scope.arrs.splice($index,1);
                    }).error(function (result) {
                        alert("删除失败")
                    })
                }
            };
        }
        $scope.apply = function($index){
            if ($index>=0) {
                if(confirm("是否提交"+$scope.arrs[$index].sn+"的申请") ){
                    $http({
                        method:"POST",
                        url:'/OA/enrolclazz/apply',
                        data:$.param({id:$scope.arrs[$index].id}),
                        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
                    }).success(function (result) {
                        if(result.ok==true){
                            alert("申请成功！")
                            window.location.reload()
                        }
                        window.location.reload()
                    }).error(function (result) {
                        alert("申请失败！")
                    })
                }
            };
        }
    })
    // 退课单列表;
    $http({
        method:"POST",
        url:"/OA/dropclazz/list",
        data:$.param({pact_id:$scope.pact_id}),
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    }).success(function (response){
        console.log(response)
        $scope.drop_datas = response.data;
        // 定义一个单击删除按钮时触发的事件，用于删除选中行
        $scope.refunddelete = function($index){
            if ($index>=0) {
                if(confirm("是否删除退课") ){
                    $http({
                        method:"POST",
                        url:'/OA/dropclazz/delete ',
                        data:$.param({id: $scope.drop_datas[$index].id}),
                        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
                    }).success(function (result) {
                        if(result.ok==true){
                            $scope.drop_datas.splice($index,1);
                        }
                    })
                }
            };
        }
        $scope.refundapply = function($index){
            if ($index>=0) {
                if(confirm("是否申请退课") ){
                    $http({
                        method:"POST",
                        url:'/OA/dropclazz/apply ',
                        data:$.param({id: $scope.drop_datas[$index].id}),
                        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
                    }).success(function (result) {
                        if(result.ok==true){
                           setTimeout(function () {
                              window.location.reload()
                           },1)
                        }
                    })
                }
            };
        }
    })
    // 补交单列表;
    $http({
        method:"POST",
        url:"/OA/mend/list",
        data:$.param({pact_id:$scope.pact_id}),
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    }).success(function (response){
        console.log(response)
        $scope.mend_datas = response.data;
        $scope.mend_apply = function($index){
            if ($index>=0) {
                if(confirm("是否提交此条申请记录") ){
                    $http({
                        method:"POST",
                        url:'/OA/mend/apply?type=2',
                        data:$.param({id:$scope.mend_datas[$index].id}),
                        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
                    }).success(function (result) {
                        if(result.ok==true){
                            setTimeout(function () {
                                window.location.reload()
                            },1)
                        }else{
                            alert("申请失败,请重新申请!")
                        }
                    })
                }
            };
        }
    })
    // 学员信息展示 合同
    $http({
        method:"POST",
        url:"/OA/clazz/query ",
        data:$.param({id:$scope.pact_id}),
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    }).success(function (response){
        console.log(response)
        $scope.findstudent=response.data;
        // 调入校区
        $scope.submits=function () {
            var campus_id=$("#schoolcampus").find("option:selected").val();
            $scope.id=$scope.findstudent.student_id;
            $http({
                method:"POST",
                url:"/OA/student/update?is_from=1",
                data:$.param({campus_id:campus_id,id:$scope.id}),
                headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
            }).success(function (response) {
                if(response.ok==true){
                    alert("调拨成功！")
                }
            })
        }
       // 学费信息修改
        $scope.updata=function () {
         var sale_id=$("#saleclass").find("option:selected").val();
         var sale_name=$("#saleclass").find("option:selected").text();
         var id= $scope.pact_id;
         var sale_derate=$scope.sale_derate;
         var sale_tuition=$scope.sale_tuition;
         var tuition_should=$scope.should_tuition;
         var tuition_lack=$scope.owed_tuition;
            $http({
                method:"POST",
                url:"/OA/clazz/update",
                data:$.param({id:id,sale_id:sale_id,sale_name:sale_name,sale_derate:sale_derate,sale_tuition:sale_tuition,tuition_should:tuition_should,tuition_lack:tuition_lack}),
                headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
            }).success(function (response) {
                if(response.ok==true){
                    alert("修改成功！")
                }
            })
        }
    })
    //班课报课情况
    $http({
        method:"POST",
        url:"/OA/subjectpactclazz/list ",
        data:$.param({pact_id:$scope.pact_id}),
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    }).success(function (response){
        console.log(response)
        $scope.subjectpactclazz=response.data;
    })
})

